function LuaMain()
   
    CreatARcamerUI();
 end
 VideoButton2State=false;
 PhotoButton2State=false;
 VideoStart=false;
 lastTime = 0;
 curTime=0;
 UI_ARCamer={
     Distinguish=nil, --扫描
     CameraButton=nil,
     FlashOffButton=nil,
     FlashAutoButton=nil,
     FlashOnButton=nil,
     VideoButton=nil,
     AboutButton=nil,
     PhotoButton=nil,
     VideoButton2=nil,
     PhotoButton2=nil,
     Tips=nil,
     VideoTime=nil,
     Image=nil,
     SpotImage=nil,
     VideoButton3=nil,
     ListButton=nil,
 };
 
 UI_About={
     Button1=nil,
     Button2=nil,
     Text1=nil,
     Text2=nil,
     BackButton=nil,
 };
 ---CreatARcanerUI----
 CreatARcamerUI=function()
 ----------------------加载声音--------------------
     local ab=self:Lua_GetBundle("audio","audio",isCopy);
     AudioToor = CS.UnityEngine.Object.Instantiate(ab:LoadAsset("audio").gameObject).gameObject;
     self.objectManager:AddModularGameObject("Audio",AudioToor);
     Audio1=self.objectManager:fandGameobject("Audio","1");
     Audio2=self.objectManager:fandGameobject("Audio","2");
     Audio3=self.objectManager:fandGameobject("Audio","3");
     Audio4=self.objectManager:fandGameobject("Audio","4");
 ---------------------------------------------------
 ----------------------加载arUI--------------------
 
 UI_ARCamer.ListButton=self.objectManager:fandGameobject("ListButton");
 
      ab=self:Lua_GetBundle("ui","arcamer",isCopy);
     ARcamerUI = CS.UnityEngine.Object.Instantiate(ab:LoadAsset("arcamer").gameObject).gameObject;
     ARcamerUI.transform:SetParent(Canvas.transform);
     self.objectManager:AddModularGameObject("ARcamer",ARcamerUI);
     local ARcamerUITransform=ARcamerUI:GetComponent("RectTransform");
     ARcamerUITransform.localScale=CS.UnityEngine.Vector3.one;
     ARcamerUITransform.sizeDelta=CS.UnityEngine.Vector2(0,0);
     ARcamerUITransform.localPosition=CS.UnityEngine.Vector3.zero;   
     ARcamerUITransform:SetSiblingIndex(1);
     ARcamerUI:SetActive(true);
 
     UI_ARCamer.ListButton.transform:SetParent(ARcamerUI.transform);
 ----------------------------------------------
     UI_ARCamer.Distinguish=self.objectManager:fandGameobject("ARcamer","Distinguish");
 --------------------切换摄像头------------------
     UI_ARCamer.CameraButton=self.objectManager:fandGameobject("ARcamer","CameraButton");
     UI_ARCamer.CameraButton:GetComponent("Button").onClick:AddListener(OnCameraButtonClick);
 --------------------关闭闪光灯------------------ 
     UI_ARCamer.FlashOffButton=self.objectManager:fandGameobject("ARcamer","FlashOffButton");
     UI_ARCamer.FlashOffButton:GetComponent("Button").onClick:AddListener(OnFlashOffButtonClick);
 --------------------自动闪光灯------------------ 
     UI_ARCamer.FlashAutoButton=self.objectManager:fandGameobject("ARcamer","FlashAutoButton");
     UI_ARCamer.FlashAutoButton:GetComponent("Button").onClick:AddListener(OnFFlashAutoButtonClick);
 --------------------开启闪光灯------------------ 
     UI_ARCamer.FlashOnButton=self.objectManager:fandGameobject("ARcamer","FlashOnButton");
     UI_ARCamer.FlashOnButton:GetComponent("Button").onClick:AddListener(OnFlashOnButtonClick);
 --------------------录像暂停-------------------- 
     UI_ARCamer.VideoButton=self.objectManager:fandGameobject("ARcamer","VideoButton");
     UI_ARCamer.VideoButton:GetComponent("Button").onClick:AddListener(OnVideoButtonClick);
     UI_ARCamer.VideoButton:SetActive(false);
 ----------------------关于按钮------------------
     UI_ARCamer.AboutButton=self.objectManager:fandGameobject("ARcamer","AboutButton");
     UI_ARCamer.AboutButton:GetComponent("Button").onClick:AddListener(OnAboutButtonClick);
 -------------------拍照 录像 按钮----------------
     UI_ARCamer.PhotoButton=self.objectManager:fandGameobject("ARcamer","PhotoButton");
     UI_ARCamer.PhotoButton:GetComponent("Button").onClick:AddListener(OnPhotoButtonClick);
     UI_ARCamer.PhotoButton:SetActive(true);
 ---------------------切换视频按钮----------------  
     UI_ARCamer.VideoButton2=self.objectManager:fandGameobject("ARcamer","VideoButton2");
     UI_ARCamer.VideoButton2:GetComponent("Button").onClick:AddListener(OnVideoButtonClick2);
 ---------------------切换拍照按钮---------------- 
     UI_ARCamer.PhotoButton2=self.objectManager:fandGameobject("ARcamer","PhotoButton2");
     UI_ARCamer.PhotoButton2:GetComponent("Button").onClick:AddListener(OnPhotoButtonClick2);
 ---------------------切换拍照按钮----------------  
     UI_ARCamer.Image=self.objectManager:fandGameobject("ARcamer","Image");
     local Imageransform=UI_ARCamer.Image:GetComponent("RectTransform");
     --Imageransform.localScale=CS.UnityEngine.Vector3.one;
     --Imageransform.sizeDelta=CS.UnityEngine.Vector2(0,0);
     Imageransform.localPosition=CS.UnityEngine.Vector3(145,Imageransform.localPosition.y+30,0); 
     UI_ARCamer.SpotImage=self.objectManager:fandGameobject("ARcamer","SpotImage");
 
     UI_ARCamer.Tips=self.objectManager:fandGameobject("ARcamer","Tips");
     UI_ARCamer.Tips:SetActive(false);
     UI_ARCamer.VideoTime=self.objectManager:fandGameobject("ARcamer","VideoTime");
     UI_ARCamer.VideoTime:SetActive(false);
     Scan=self.objectManager:fandGameobject("ARcamer","Scan");
     Scan:SetActive(false);
     UI_ARCamer.VideoButton3=self.objectManager:fandGameobject("ARcamer","PhotoButton (1)");
     UI_ARCamer.VideoButton3:GetComponent("Button").onClick:AddListener(OnPhotoButtonClick);
     UI_ARCamer.VideoButton3:SetActive(false);
 
     UI_ARCamer.FlashAutoButton:SetActive(false);
     UI_ARCamer.FlashOffButton:SetActive(true);
     UI_ARCamer.FlashOnButton:SetActive(false);
     UI_ARCamer.ListButton:SetActive(true);
     UI_ARCamer.Image:SetActive(true);
     isStartPhtot=false;
 
     self:Setjomp_Spto(jomp_Spto);
     OnPhotoButtonClick2();
 --临时按钮
 tmpFlashButton = UI_ARCamer.FlashOffButton;
 
 
 ---------------
 ab=self:Lua_GetBundle("ui","about",isCopy);
 AboutUI2 = CS.UnityEngine.Object.Instantiate(ab:LoadAsset("about").gameObject).gameObject;
 AboutUI2.transform:SetParent(Canvas.transform);
 self.objectManager:AddModularGameObject("About",AboutUI2);
 local AboutUI2Transform=AboutUI2:GetComponent("RectTransform");
 AboutUI2Transform.localScale=CS.UnityEngine.Vector3.one;
 AboutUI2Transform.sizeDelta=CS.UnityEngine.Vector2(0,0);
 AboutUI2Transform.localPosition=CS.UnityEngine.Vector3.zero;   
 AboutUI2Transform:SetSiblingIndex(1);
 AboutUI2:SetActive(false);
 
 UI_About.BackButton=self.objectManager:fandGameobject("About","BackButton");
 UI_About.BackButton:GetComponent("Button").onClick:AddListener(OnAbout_BackButtonClick);
 
 UI_About.Button2=self.objectManager:fandGameobject("About","Button2");
 UI_About.Button2:GetComponent("Button").onClick:AddListener(function() 
 Audio2:SetActive(false);
 Audio2:SetActive(true);
 
    SetPromptUI(isUpdate_PromptBack,"确 定",false,"缓存清除完成！！！") end);
 
 UI_About.Button1=self.objectManager:fandGameobject("About","Button1");
 UI_About.Button1:GetComponent("Button").onClick:AddListener(function() 
 
 Audio2:SetActive(false);
 Audio2:SetActive(true);
    self:InvokeFOLua(function() 
        CS.UnityEngine.Application.OpenURL("http://www.xiaomayunkeji.com"); 
    end,1);
     
    end);
 
 
 
 UI_About.Text1=self.objectManager:fandGameobject("About","Text1");
 text=UI_About.Text1:GetComponent("Text");
 text.lineSpacing=1
 
 
 
 -------luamain end ------
 end
 
 
 
 
 CameraFront=false;
 --切换摄像头
 function OnCameraButtonClick()  
 
     Audio2:SetActive(false);
     Audio2:SetActive(true);
     if(CameraFront==false)then
         self.aRcameraManager:OpenCameraFront();
         CameraFront=true;
         return;
     end
     self.aRcameraManager:OpenCameraBack();
     CameraFront=false;
     print("OnCameraButtonClick");
 end
 IsFlash=false;
 isShwoUI=false;
 --关闭闪光灯
 function OnFlashOffButtonClick()  
     print("OnFlashOffButtonClick");
   
     if(isShwoUI==false)then
         isShwoUI=true;
         UI_ARCamer.FlashAutoButton:SetActive(true);
         UI_ARCamer.FlashOffButton:SetActive(true);
         UI_ARCamer.FlashOnButton:SetActive(true);
         Audio2:SetActive(false);
         Audio2:SetActive(true);
     else
         Audio2:SetActive(false);
         Audio2:SetActive(true);
         UI_ARCamer.FlashOffButton:SetActive(true);
         --获取上次选择按钮的位置
        tmpT2= UI_ARCamer.FlashOffButton:GetComponent("RectTransform");
        tmpTv= UI_ARCamer.FlashOffButton:GetComponent("RectTransform").localPosition;
 
        tmpT3= tmpFlashButton:GetComponent("RectTransform");
 
        tmpT2.localPosition=CS.UnityEngine.Vector3(tmpT3.localPosition.x,tmpT3.localPosition.y,tmpT3.localPosition.z);
 
        tmpT3.localPosition=CS.UnityEngine.Vector3(tmpTv.x,tmpTv.y,tmpTv.z);
         tmpFlashButton=UI_ARCamer.FlashOffButton
   
         isShwoUI=false;
         UI_ARCamer.FlashAutoButton:SetActive(false);
         UI_ARCamer.FlashOnButton:SetActive(false);
 
         self.aRcameraManager:stopFlash();
         IsFlash=false;
     end
 
 
 
 end
 --自动
 
 function OnFFlashAutoButtonClick()
     print("OnFFlashAutoButtonClick");
     if(isShwoUI==false)then
         isShwoUI=true;
         UI_ARCamer.FlashAutoButton:SetActive(true);
         UI_ARCamer.FlashOffButton:SetActive(true);
         UI_ARCamer.FlashOnButton:SetActive(true);
         Audio2:SetActive(false);
         Audio2:SetActive(true);
     else
         Audio2:SetActive(false);
         Audio2:SetActive(true);
         UI_ARCamer.FlashAutoButton:SetActive(true);
     
        tmpT2= UI_ARCamer.FlashAutoButton:GetComponent("RectTransform");
        tmpTv= UI_ARCamer.FlashAutoButton:GetComponent("RectTransform").localPosition;
 
        tmpT3= tmpFlashButton:GetComponent("RectTransform");
 
        tmpT2.localPosition=CS.UnityEngine.Vector3(tmpT3.localPosition.x,tmpT3.localPosition.y,tmpT3.localPosition.z);
 
        tmpT3.localPosition=CS.UnityEngine.Vector3(tmpTv.x,tmpTv.y,tmpTv.z);
         tmpFlashButton=UI_ARCamer.FlashAutoButton
   
         isShwoUI=false;
         UI_ARCamer.FlashOnButton:SetActive(false);
         UI_ARCamer.FlashOffButton:SetActive(false);
         self.aRcameraManager:stopFlash();
         IsFlash=true;
     end
 
     
 end
 --开启闪光灯
 function OnFlashOnButtonClick()
     
     print("OnFlashOnButtonClick");
 
     if(isShwoUI==false)then
         isShwoUI=true;
         UI_ARCamer.FlashAutoButton:SetActive(true);
         UI_ARCamer.FlashOffButton:SetActive(true);
         UI_ARCamer.FlashOnButton:SetActive(true);
         Audio2:SetActive(false);
         Audio2:SetActive(true);
     else
         Audio2:SetActive(false);
         Audio2:SetActive(true);
         UI_ARCamer.FlashOnButton:SetActive(true);
  
        tmpT2= UI_ARCamer.FlashOnButton:GetComponent("RectTransform");
        tmpTv= UI_ARCamer.FlashOnButton:GetComponent("RectTransform").localPosition;
 
        tmpT3= tmpFlashButton:GetComponent("RectTransform");
 
        tmpT2.localPosition=CS.UnityEngine.Vector3(tmpT3.localPosition.x,tmpT3.localPosition.y,tmpT3.localPosition.z);
 
        tmpT3.localPosition=CS.UnityEngine.Vector3(tmpTv.x,tmpTv.y,tmpTv.z);
         tmpFlashButton=UI_ARCamer.FlashOnButton
   
         isShwoUI=false;
         UI_ARCamer.FlashAutoButton:SetActive(false);
         UI_ARCamer.FlashOffButton:SetActive(false);
         self.aRcameraManager:startFlash();
         IsFlash=false;
     end
 
 end
 --录像暂停
 function OnVideoButtonClick()
     print("OnVideoButtonClick");
     if(second>1) then
         StopRecord();
         return;
     end
     
 end
 --关于
 function OnAboutButtonClick()
     print("OnAboutButtonClick");
     self.aRcameraManager:StopCapture();
     ARcamerUI:SetActive(false);
     print("OnAboutButtonClick1");
 
     if(AboutUI2==nil)then
     print("nilllll");
 end
 
     AboutUI2:SetActive(true);
     print("OnAboutButtonClick2");
     Audio2:SetActive(false);
     Audio2:SetActive(true);
     
 end
 function OnAbout_BackButtonClick()
 
    
     Audio2:SetActive(false);
     Audio2:SetActive(true);
     self.aRcameraManager:StartCapture();
     ARcamerUI:SetActive(true);
     AboutUI2:SetActive(false);
     
 end
 --拍照 录像 按钮
 function OnPhotoButtonClick()
     if (VideoButton2State==false) then
        
         Audio1:SetActive(false);
         Audio1:SetActive(true);
         for k, v in pairs(UI_ARCamer) do
             v:SetActive(false);
            
         end
         UI_ARCamer.Image:SetActive(true);
         if(IsFlash==true) then
             self.aRcameraManager:startFlash();
         end
     self.aRcameraManager:OnClickTakePicturesButton(
             function(s) 
                 for k, v in pairs(UI_ARCamer) do
                     v:SetActive(true);
                     UI_ARCamer.VideoTime:SetActive(false);
                     UI_ARCamer.VideoButton3:SetActive(false);
                     UI_ARCamer.FlashAutoButton:SetActive(false);
                     UI_ARCamer.FlashOffButton:SetActive(false);
                     UI_ARCamer.FlashOnButton:SetActive(false);
                     tmpFlashButton:SetActive(true);
                    -- tmpFlashButton:SetActive(true);
                 end
                 self:SHowUI();
                 self:InvokeFOLua(function() 
                     UI_ARCamer.VideoTime:SetActive(false);
                     UI_ARCamer.Tips:SetActive(false);
                     UI_ARCamer.VideoButton:SetActive(false);
                     
                     --UI_ARCamer.Image:SetActive(false);
                 end,2);
                 self.aRcameraManager:stopFlash();
             end);
     end
     if (VideoButton2State==true) then
         UI_ARCamer.VideoButton:SetActive(true);
         Audio2:SetActive(false);
         Audio2:SetActive(true);
         if(VideoStart==false) then
 
             VideoStart=true;
             self.aRcameraManager:StartRecord();
             lastTime=CS.UnityEngine.Time.time;
             UI_ARCamer.VideoTime:SetActive(true);
             UI_ARCamer.VideoButton3:SetActive(false);
             UI_ARCamer.VideoButton2:SetActive(false);
             UI_ARCamer.PhotoButton2:SetActive(false);
             UI_ARCamer.AboutButton:SetActive(false);
             UI_ARCamer.Distinguish:SetActive(false);
             UI_ARCamer.CameraButton:SetActive(false);
             UI_ARCamer.FlashAutoButton:SetActive(false);
             UI_ARCamer.FlashOffButton:SetActive(false);
             UI_ARCamer.FlashOnButton:SetActive(false);
             UI_ARCamer.SpotImage:SetActive(false);
             UI_ARCamer.Image:SetActive(false);
             UI_ARCamer.ListButton:SetActive(false);
          else
             StopRecord();
         end
     end
 
     print("OnPhotoButtonClick");
 end
 
 
 
 Video2V3off=CS.UnityEngine.Vector3(-67,-271,0);
 Video2V3on=CS.UnityEngine.Vector3(0.5,-271,0);
 
 Photo2V3off=CS.UnityEngine.Vector3(67,-271,0);
 Photo2V3on=CS.UnityEngine.Vector3(0.5,-271,0);
 
 function OnVideoButtonClick2()
     print("OnVideoButtonClick2");
     AVideoButton2Transform=UI_ARCamer.VideoButton2:GetComponent("RectTransform");
     PhotoButton2Transform=UI_ARCamer.PhotoButton2:GetComponent("RectTransform");
     Audio2:SetActive(false);
     Audio2:SetActive(true);
     if (VideoButton2State==false) then
         y=AVideoButton2Transform.localPosition.y;
         AVideoButton2Transform.localPosition=CS.UnityEngine.Vector3(0.5,y,0);
         y1=PhotoButton2Transform.localPosition.y;
         PhotoButton2Transform.localPosition=CS.UnityEngine.Vector3(67,y1,0);
  
         
         UI_ARCamer.VideoButton3:SetActive(true);
         UI_ARCamer.PhotoButton:SetActive(false);
         VideoButton2State=true;
         PhotoButton2State=false;
 
     end
     
 end
 function OnPhotoButtonClick2()
     print("OnPhotoButtonClick2");
     if(isStartPhtot==true) then
         Audio2:SetActive(false);
         Audio2:SetActive(true);
     end
     isStartPhtot=true;
     if (VideoStart==false)then
         AVideoButton2Transform=UI_ARCamer.VideoButton2:GetComponent("RectTransform");
         PhotoButton2Transform=UI_ARCamer.PhotoButton2:GetComponent("RectTransform");
         if (PhotoButton2State==false)then
 
             y=AVideoButton2Transform.localPosition.y;
             AVideoButton2Transform.localPosition=CS.UnityEngine.Vector3(-67,y,0);
             y1=PhotoButton2Transform.localPosition.y;
             PhotoButton2Transform.localPosition=CS.UnityEngine.Vector3(0.5,y1,0);
            -- UI_ARCamer.PhotoButton:GetComponent("Image").color=CS.UnityEngine.Color.white
             PhotoButton2State=true;
             VideoButton2State=false;
             UI_ARCamer.VideoButton3:SetActive(false);
             UI_ARCamer.PhotoButton:SetActive(true);
         end
     end     
 end
 
 
 vtime=0;
 Minute=0;
 second=0;
 function LuaUpdate()
     if(VoideObj3.transform.localScale.x==16)then
       VoideObj3.transform.localScale=CS.UnityEngine.Vector3(16,3,9)
     end
     if (VideoStart==true) then
         curTime = CS.UnityEngine.Time.time;
         if (curTime - lastTime >= 1) then
             second=second+1;
           
                 UI_ARCamer.VideoTime:GetComponent("Text").text=Minute..":0"..second;
             if(second>9) then
                 UI_ARCamer.VideoTime:GetComponent("Text").text=Minute..":"..second;
             end
             if(second>59) then
                 Minute=Minute+1;
                 second=0;
                 UI_ARCamer.VideoTime:GetComponent("Text").text=Minute..":"..second;
             end
             lastTime = curTime;
             if(second==15) then
                 --StopRecord();
             end
         end
 
     end
 end
 function StopRecord()
     Audio3:SetActive(false);
     Audio3:SetActive(true);
     vtime=0;
     Minute=0;
     second=0;
     UI_ARCamer.Tips:SetActive(true);
     self:InvokeFOLua(function() 
 
         UI_ARCamer.Tips:SetActive(false);
        
     end,2);
 
     VideoStart=false;
     UI_ARCamer.VideoButton3:SetActive(true);
     UI_ARCamer.VideoTime:SetActive(false);
     UI_ARCamer.VideoButton2:SetActive(true);
     UI_ARCamer.PhotoButton2:SetActive(true);
     UI_ARCamer.AboutButton:SetActive(true);
     UI_ARCamer.Distinguish:SetActive(true);
     UI_ARCamer.CameraButton:SetActive(true);
     UI_ARCamer.FlashAutoButton:SetActive(false);
     UI_ARCamer.FlashOffButton:SetActive(false);
     UI_ARCamer.FlashOnButton:SetActive(false);
     tmpFlashButton:SetActive(true);
     UI_ARCamer.SpotImage:SetActive(true);
     self.aRcameraManager:StopRecord();
     UI_ARCamer.Image:SetActive(true);
     UI_ARCamer.ListButton:SetActive(true);
     self:SHowUI();
     UI_ARCamer.VideoTime:GetComponent("Text").text="0:00";
 end
 
 function jomp_Spto()
     if(VideoStart==true) then
          StopRecord();
     end
 end
 